import React from 'react'
import {BrowserRouter, Route, Link, Redirect, Switch} from 'react-router-dom'
import {NavBar, Icon, TabBar} from 'antd-mobile';
import {connect} from 'react-redux'
import NavLinkBar from '../navlink/navlink'
import Boss from '../boss/boss'
import Genius from '../genius/genius'
import User from '../user/user'
// function Boss() {     return <h2>牛人首页222</h2> }

function Msg() {
    return <h2>消息列表</h2>
}

@connect(state => state)

class Dashboard extends React.Component {
    // constructor(props) {     super(props) }



    render() {
        const {pathname} = this.props.location
        console.log(pathname);
        
        
        

        const user = this.props.user
        const navList = [
            {
                path: '/boss',
                text: '牛人',
                icon: 'img',
                title: '牛人列表',
                component: Boss,
                hide: user.type === 'genius'
            }, {
                path: '/genius',
                text: 'boss',
                icon: 'img',
                title: 'Boss列表',
                component: Genius,
                hide: user.type === 'boss'
            }, {
                path: '/msg',
                text: '消息',
                icon: 'img',
                title: '消息列表',
                component: Msg
            }, {
                path: '/me',
                text: '我',
                icon: 'img',
                title: '个人中心',
                component: User
            }
        ]   
        //console.log(pathname)

        return (

                

            
            <div>
                <NavBar
                    className='fixd-header'
                    mode="dark"
                    icon={< Icon type = "left" />}
                    rightContent={[< Icon key = "1" type = "ellipsis" / >]}>{navList
                        .find(v => v.path === pathname)
                        .title}</NavBar>
                <div style={{
                    marginTop: 45
                }}>
                    <Switch>
                        {navList.map(v => (
                            <Route key={v.path} path={v.path} component={v.component}></Route>
                        ))}
                        {/* <Route path='/boss' component={Boss}></Route> */}
                        {/* <Route path='/genius' component={Boss}></Route> */}
                    </Switch>

                </div>
                <div id='mybar'>
                    <NavLinkBar   data={navList}></NavLinkBar>
                </div>
            </div>
        )
    }
}

export default Dashboard